package com.comunicacion2.heatmap;

public class Location implements Comparable<Location> {

	private final int x;

	private final int y;

	public Location(int x, int y) {
		this.x = x;
		this.y = y;
	}

	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}

	public int compareTo(Location o) {
		if (x > o.getX()) {
			return 1;
		} else if (x == o.getX()) {
			if (y > o.getY()) {
				return 1;
			} else if (y == o.getY()) {
				return 0;
			} else {
				return -1;
			}
		} else {
			return -1;
		}
	}

	public boolean equals(Object obj) {
		if (obj == null)
			return false;
		if (obj == this)
			return true;
		if (!(obj instanceof Location))
			return false;

		Location location = (Location) obj;
		return getX() == location.getX() && getY() == location.getY();
	}
}
